package com.lsa.letcode.the83.deleteDuplicates;

import static org.junit.Assert.*;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.ListNode;

public class DeleteDuplicatesTest extends LetCodeTestBase{
	@Test
	public void test() {
		Solution s = new Solution();
		test(s, asList(), asList());
		test(s, asList(1), asList(1));
		test(s, asList(1, 2, 3, 4, 5, 6, 7),
				asList(1, 2, 3, 4, 5, 6, 7));
		test(s, asList(1, 2, 3, 4, 5, 6, 7, 8),
				asList(1, 2, 3, 4, 5, 6, 7, 8));
		test(s, asList(1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 8),
				asList(1, 2, 3, 4, 5, 6, 7, 8));
		test(s, asList(1, 1, 1), asList(1));
		test(s, asList(1, 1, 1, 1, 1), asList(1));
		test(s, asList(5, 1, 1, 1), asList(5, 1));
		test(s, asList(1, 1, 1, 5), asList(1, 5));
		test(s, asList(1, 1, 2, 2, 2, 3, 3, 3, 4), asList(1, 2, 3, 4));
	}

	private void test(Solution s, ListNode input, ListNode expected) {
		ListNode actual = s.deleteDuplicates(input);
		assertTrue(String.format("expected:%s, actual:%s", expected, actual), areEqual(expected, actual));
	}
}
